﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;

namespace Streaming_Service.Media {
    using Enum;

    [DataContract]
    public class MovieEntry {
        // Id of the movie.
        [DataMember]
        public int Id { get; set; }

        // Title of the movie (can be partial when used for searching)
        [DataMember]
        public string Title { get; set; }

        // Year of the movie
        [DataMember]
        public int Year { get; set; }

        // Language of the movie (might be changed to an Enum instead)
        [DataMember]
        public string Language { get; set; }

        // Is the movie in HD or not.
        [DataMember]
        public XBool HighDefinition { get; set; }

        // The genre(s) of the movie (might be changed to Enums instead)
        [DataMember]
        public List<GenreEntry> Genre { get; set; }

        // The parental guidance for the movie
        [DataMember]
        public ParentalGuidance ParentalGuidance { get; set; }

        // Length of the movie in minutes
        [DataMember]
        public int Length { get; set; }

        // Length formatted
        [DataMember]
        public string LengthFormatted {
            get {
                int hours = (Length/60);
                int mins = Length - (hours*60);
                return string.Format("{0:00}:{1:00}", hours, mins);
            }
            set {
                //
            }
        }

        // The rent price for a non-HD quality version of the movie
        [DataMember]
        public decimal SdPrice { get; set; }

        // The rent price for a HD quality version of the movie
        [DataMember]
        public decimal HdPrice { get; set; }

        // The release date for the movie.
        // When searching you can specify in groups: 
        // - year: Will search for movies from the specified year.
        // - year, month: Will search for movies from the specified year and month.
        // - year, month, day: Will search for movies from the specified year, month and day.
        [DataMember]
        public DateTime? ReleaseDate { get; set; }

        // The summary for the movie.
        [DataMember]
        public string Summary { get; set; }

        // The download movie url.
        [DataMember]
        public string MovieDownloadUrl {
            get { return "http://rentit.itu.dk/rentit11/Web/moviedownload.aspx?vid=" + Id; }
            set {
                //
            }
        }

        // The download HD movie url.
        [DataMember]
        public string MovieDownloadUrlHD {
            get { return "http://rentit.itu.dk/rentit11/Web/moviedownload.aspx?vid=" + Id + "&hd=1"; }
            set {
                //
            }
        }

        // The image thumb url.
        [DataMember]
        public string ThumbUrl {
            get {
                var u = MediaFunc.RootUrl() + "Web/thumbimg.aspx?vid=" + Id;
                return u;
            }
            set {
                //
            }
        }

        // The imdb ID of the movie
        [DataMember]
        public string ImdbId { get; set; }

        public MovieEntry() {
            Id = -1;
            Title = null;
            Year = -1;
            Language = null;
            HighDefinition = XBool.Ignore;
            Genre = null;
            ParentalGuidance = ParentalGuidance.Ignore;
            Length = -1;
            HdPrice = -1;
            SdPrice = -1;
            ReleaseDate = null;
            ImdbId = null;
        }
    }
}